package com.cleaningcloud.erp.mapper;

import com.cleaningcloud.erp.domain.ErpProcure;
import com.cleaningcloud.erp.domain.dto.ErpProcureDto;
import com.cleaningcloud.erp.domain.vo.ErpProcureVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 采购单Mapper接口
 *
 * @author cleaningcloud
 * @date 2024-09-26
 */
@Mapper
public interface ErpProcureMapper {
    /**
     * 查询采购单
     *
     * @param procureId 采购单主键
     * @return 采购单
     */
    ErpProcureVo selectErpProcureByProcureId(Long procureId);

    /**
     * 查询采购单列表
     *
     * @param erpProcure 采购单
     * @return 采购单集合
     */
    List<ErpProcureVo> selectErpProcureList(ErpProcureDto erpProcure);

    /**
     * 新增采购单
     *
     * @param erpProcure 采购单
     * @return 结果
     */
    int insertErpProcure(ErpProcure erpProcure);

    /**
     * 修改采购单
     *
     * @param erpProcure 采购单
     * @return 结果
     */
    int updateErpProcure(ErpProcure erpProcure);

    /**
     * 删除采购单
     *
     * @param procureId 采购单主键
     * @return 结果
     */
    int deleteErpProcureByProcureId(Long procureId);

    /**
     * 批量删除采购单
     *
     * @param procureIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteErpProcureByProcureIds(Long[] procureIds);

    /**
     * 根据供应商id查询审核通过的采购单数量
     *
     * @param supplierId
     * @return
     */
    @Select("select count(1) from erp_procure where supplier_id = #{supplierId} and procure_status = 2")
    int queryApprovedBySupplierId(@Param("supplierId") Long supplierId);

    /**
     * 根据采购单号查询
     *
     * @param procureNo
     * @return
     */
    ErpProcureVo getProcureByProcureNo(@Param("procureNo") String procureNo);

}
